
import javax.swing.*;
import java.awt.*;

public class register extends JFrame {
    private JTextField userId,userName;
    private JRadioButton sexFemale,sexMale;
    private JPanel sex,birth;
    private JTextField year,dept;
    private JComboBox month,day,prof;
    private JButton ok,cancel;

    public register(){
        super();
        this.setSize(350,300);
        this.setTitle("登录");
        this.setLocationRelativeTo(getOwner());
        //设置组件布局
        Container container = getContentPane();
        container.setLayout(new GridLayout(7,2));
        //添加组件
        container.add(new JLabel("读者编号"));
        userId = new JTextField(10);
        container.add(userId);
        //用户名
        container.add(new JLabel("读者姓名"));
        userName = new JTextField(10);
        container.add(userName);
        //性别
        container.add(new JLabel("性别"));
        sexMale = new JRadioButton("男",true);
        sexFemale = new JRadioButton("女");
        ButtonGroup bg = new ButtonGroup();
        bg.add(sexMale);
        bg.add(sexFemale);
        sex = new JPanel(new GridLayout(1,2));
        sex.add(sexMale);
        sex.add(sexFemale);
        container.add(sex);
        //出生日期
        container.add(new JLabel("登记日期"));
        year = new JTextField(4);
        month = new JComboBox();
        day = new JComboBox();
        for (int i = 1; i <13; i++) {
            month.addItem(i);
        }
        for (int i = 1; i <32; i++) {
            day.addItem(i);
        }
        birth = new JPanel();
        birth.add(year);
        birth.add(new JLabel("-"));
        birth.add(month);
        birth.add(new JLabel("-"));
        birth.add(day);
        container.add(birth);
        //职称
        container.add(new JLabel("权限"));
        prof = new JComboBox();
        prof.addItem("普通读者");
        prof.addItem("管理员");
        prof.addItem("超级管理员");
        container.add(prof);
        //部门
        container.add(new JLabel("工作单位"));
        dept = new JTextField(10);
        container.add(dept);
        //按钮
        ok = new JButton("注册");
        cancel = new JButton("取消");
        container.add(ok);
        container.add(cancel);



        //___end_____
    }

    public static void main(String[] args) {
        register w = new register();
        w.setVisible(true);
    }
}
